import {
  ajax,
} from '../../utils/http-request.js';
import {
  requestBaseUrl,
} from '../../utils/common.js';

/**
 * 查询设备信息
 */
export const getEquipmentInfo = (param) => {
  const url = `om/equipment/getEquipmentInfo`;
  return ajax(url, param);
};

/**
 * 查询维修工单列表
 */
export const getOrderList = (param = {}) => {
  const url = `om/repairworkorder/myorderlist`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询保养工单列表
 */
export const getStandOrderList = (param = {}) => {
  const url = `om/maintenanceworkorder/myorderlist`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询巡检工单列表
 */
export const getCheckOrderList = (param = {}) => {
  const url = `om/inspectworkorder/myorderlist`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询计量工单列表
 */
export const getMeasureOrderList = (param = {}) => {
  const url = `om/measureworkorder/myorderlist`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询维修工单详情
 */
export const getOrderDetail = (param = {}) => {
  const url = `om/repairworkorder/getWorkOrderInfo`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询保养工单详情
 */
export const getStandOrderDetail = (param = {}) => {
  const url = `om/maintenanceworkorder/getWorkOrderInfo`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询巡检工单详情
 */
export const getCheckOrderDetail = (param = {}) => {
  const url = `om/inspectworkorder/getWorkOrderInfo`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询计量工单详情
 */
export const getMeasureOrderDetail = (param = {}) => {
  const url = `om/measureworkorder/getWorkOrderInfo`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 创建工单
 */
export const createOrder = (param = {}) => {
  const url = `om/repairrequest/submitApply`;
  return ajax(url, param);
};

/**
 * 提交维修工单
 */
export const commitOrder = (param = {}) => {
  const url = `om/repairworkorder/complete`;
  return ajax(url, param);
};

/**
 * 提交保养工单
 */
export const commitStandOrder = (param = {}) => {
  const url = `om/maintenanceworkorder/complete`;
  return ajax(url, param);
};

/**
 * 提交巡检工单
 */
export const commitCheckOrder = (param = {}) => {
  const url = `om/inspectworkorder/complete`;
  return ajax(url, param);
};

/**
 * 提交计量工单
 */
export const commitMeasureOrder = (param = {}) => {
  const url = `om/measureworkorder/complete`;
  return ajax(url, param);
};

/**
 * 上传维修图片
 */
export const getUploadImgUrl = () => {
  return `${requestBaseUrl}/om/repairworkorder/uploadImage`;
};

/**
 * 上传保养图片
 */
export const getStandUploadImgUrl = () => {
  return `${requestBaseUrl}/om/maintenanceworkorder/uploadImage`;
};

/**
 * 上传巡检图片
 */
export const getCheckUploadImgUrl = () => {
  return `${requestBaseUrl}/om/inspectworkorder/uploadImage`;
};

/**
 * 查询维修工单状态
 * @param param
 * @returns {Promise<*>}
 */
export const getRepairOrderStatus = (param = {}) => {
  const url = `om/repairworkorder/getWorkOrderInfoUp`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询保养工单状态
 * @param param
 * @returns {Promise<*>}
 */
export const getStandOrderStatus = (param = {}) => {
  const url = `om/maintenanceworkorder/getWorkOrderInfoUp`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询巡检工单状态
 * @param param
 * @returns {Promise<*>}
 */
export const getCheckOrderStatus = (param = {}) => {
  const url = `om/inspectworkorder/getWorkOrderInfoUp`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 查询计量工单状态
 * @param param
 * @returns {Promise<*>}
 */
export const getMeasureOrderStatus = (param = {}) => {
  const url = `om/measureworkorder/getWorkOrderInfoUp`;
  return ajax(url, param, {
    method: 'get',
  });
};

/**
 * 科室人员验收
 * @param param
 * @returns {Promise<*>}
 */
export const completeOffice = (param = {}) => {
  const url = `om/repairworkorder/completeOffice`;
  return ajax(url, param, {
    // method: 'get',
  });
};

/**
 * 巡检科室人员验收
 * @param param
 * @returns {Promise<*>}
 */
export const standCompleteOffice = (param = {}) => {
  const url = `om/maintenanceworkorder/completeOffice`;
  return ajax(url, param, {
    // method: 'get',
  });
};

/**
 * 计量科室人员验收
 * @param param
 * @returns {Promise<*>}
 */
export const measureCompleteOffice = (param = {}) => {
  const url = `om/measureworkorder/completeOffice`;
  return ajax(url, param, {
    // method: 'get',
  });
};

/**
 * 未完成工单数量
 * @param param
 * @returns {Promise<*>}
 */
export const repairUncompleted = (param = {}) => {
  const url = `om/repairworkorder/uncompleted`;
  return ajax(url, param, {
    method: 'get',
  });
};


/**
 * 添加工单描述
 * @param param
 * @param orderType
 * @returns {Promise<*>}
 */
export const addOrderRemark = (param = {}, orderType) => {
  const urlObj = {
    repair: `om/repairworkorder/addRepairWorkorderDetails`,
    stand: `om/maintenanceworkorder/addMaintenanceWorkorderDetails`,
  };
  const url = urlObj[ orderType ];
  return ajax(url, param);
};


export const deviceSelfCheck = (param = {}) => {
  const url = `om/equipment/selfInspectComplete`;
  return ajax(url, param, {
    method: 'get',
  });
};

export default {
  getEquipmentInfo,
  getOrderList,
  getOrderDetail,
  createOrder,
  getUploadImgUrl,
  commitOrder,
  getStandOrderList,
  getStandUploadImgUrl,
  commitStandOrder,
  getMeasureOrderList,
  getCheckOrderList,
  getCheckOrderDetail,
  getCheckUploadImgUrl,
  commitCheckOrder,
  getMeasureOrderDetail,
  commitMeasureOrder,
  getRepairOrderStatus,
  getStandOrderStatus,
  getCheckOrderStatus,
  getMeasureOrderStatus,
  completeOffice,
  standCompleteOffice,
  measureCompleteOffice,
  repairUncompleted,
  deviceSelfCheck,
  addOrderRemark,
};
